<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>回溯（backtrack）描述 | 夜悊的技术小宅</title><meta name="author" content="夜悊"><meta name="copyright" content="夜悊"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="前言回溯描述。  一、核心概念 在深度优先搜索（DFS）的递归过程中回溯：回溯问题可抽象为树形结构，递归向下处理和获取结果，回溯向上撤销结果 相对于暴力算法，是一种间接&#x2F;有技巧（使用递归代替多重循环）的暴力搜索&#x2F;穷举，不高效   二、典型问题 分类依据：代码随想录 (programmercarl.com)和力扣   组合问题：N个数里面按一定规则找出k个数的集合 切割问题：一个">
<meta property="og:type" content="article">
<meta property="og:title" content="回溯（backtrack）描述">
<meta property="og:url" content="http://example.com/2023/02/13/%E5%9B%9E%E6%BA%AF%EF%BC%88backtrack%EF%BC%89%E6%8F%8F%E8%BF%B0/index.html">
<meta property="og:site_name" content="夜悊的技术小宅">
<meta property="og:description" content="前言回溯描述。  一、核心概念 在深度优先搜索（DFS）的递归过程中回溯：回溯问题可抽象为树形结构，递归向下处理和获取结果，回溯向上撤销结果 相对于暴力算法，是一种间接&#x2F;有技巧（使用递归代替多重循环）的暴力搜索&#x2F;穷举，不高效   二、典型问题 分类依据：代码随想录 (programmercarl.com)和力扣   组合问题：N个数里面按一定规则找出k个数的集合 切割问题：一个">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/img/cover9.png">
<meta property="article:published_time" content="2023-02-13T07:28:33.000Z">
<meta property="article:modified_time" content="2023-04-13T05:11:53.933Z">
<meta property="article:author" content="夜悊">
<meta property="article:tag" content="算法">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/img/cover9.png"><link rel="shortcut icon" href="/img/favicon2.png"><link rel="canonical" href="http://example.com/2023/02/13/%E5%9B%9E%E6%BA%AF%EF%BC%88backtrack%EF%BC%89%E6%8F%8F%E8%BF%B0/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css?v=4.13.0"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.33/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: 夜悊","link":"链接: ","source":"来源: 夜悊的技术小宅","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid@4.11.1/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '回溯（backtrack）描述',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-04-13 13:11:53'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><link rel="stylesheet" href="/css/my_css.css"><meta name="generator" content="Hexo 7.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/img/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">92</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">15</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-bookmark"></i><span> 笔记目录</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-blog"></i><span> 其他博客</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://blog.csdn.net/m0_62083249"><i class="fa-fw fa fa-link"></i><span> CSDN</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.zhihu.com/people/ye-zhe-ning"><i class="fa-fw fa fa-link"></i><span> 知乎</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-sitemap"></i><span> 代码仓库</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://gitee.com/yezhening"><i class="fa-fw fa fa-link"></i><span> Gitee</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://github.com/yezhening"><i class="fa-fw fa fa-link"></i><span> Github</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about_me/"><i class="fa-fw fas fa-user"></i><span> 关于我</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/img/cover9.png')"><nav id="nav"><span id="blog-info"><a href="/" title="夜悊的技术小宅"><span class="site-name">夜悊的技术小宅</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-bookmark"></i><span> 笔记目录</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-blog"></i><span> 其他博客</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://blog.csdn.net/m0_62083249"><i class="fa-fw fa fa-link"></i><span> CSDN</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.zhihu.com/people/ye-zhe-ning"><i class="fa-fw fa fa-link"></i><span> 知乎</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-sitemap"></i><span> 代码仓库</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://gitee.com/yezhening"><i class="fa-fw fa fa-link"></i><span> Gitee</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://github.com/yezhening"><i class="fa-fw fa fa-link"></i><span> Github</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about_me/"><i class="fa-fw fas fa-user"></i><span> 关于我</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">回溯（backtrack）描述</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-02-13T07:28:33.000Z" title="发表于 2023-02-13 15:28:33">2023-02-13</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-13T05:11:53.933Z" title="更新于 2023-04-13 13:11:53">2023-04-13</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E7%AE%97%E6%B3%95/">算法</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="回溯（backtrack）描述"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>回溯描述。</p>
<hr>
<h1 id="一、核心概念"><a href="#一、核心概念" class="headerlink" title="一、核心概念"></a>一、核心概念</h1><ul>
<li>在深度优先搜索（DFS）的递归过程中回溯：回溯问题可抽象为树形结构，递归向下<strong>处理和获取</strong>结果，回溯向上<strong>撤销</strong>结果</li>
<li>相对于暴力算法，是一种间接&#x2F;有技巧（使用递归代替多重循环）的暴力搜索&#x2F;穷举，不高效</li>
</ul>
<hr>
<h1 id="二、典型问题"><a href="#二、典型问题" class="headerlink" title="二、典型问题"></a>二、典型问题</h1><blockquote>
<p>分类依据：<a target="_blank" rel="noopener" href="https://programmercarl.com/%E5%9B%9E%E6%BA%AF%E7%AE%97%E6%B3%95%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.html">代码随想录 (programmercarl.com)</a>和力扣</p>
</blockquote>
<ul>
<li>组合问题：N个数里面按一定规则找出k个数的集合</li>
<li>切割问题：一个字符串按一定规则有几种切割方式</li>
<li>子集问题：一个N个数的集合里有多少符合条件的子集</li>
<li>排列问题：N个数按一定规则<strong>全排列</strong>，有几种排列方式</li>
<li>图问题：图中使用深度优先遍历</li>
<li>棋盘问题：N皇后，解数独等等</li>
</ul>
<hr>
<h1 id="三、算法步骤"><a href="#三、算法步骤" class="headerlink" title="三、算法步骤"></a>三、算法步骤</h1><ol start="0">
<li>将回溯问题抽象为树形结构</li>
</ol>
<ul>
<li>问题规模为树的宽度</li>
<li>递归深度为树的深度</li>
</ul>
<ol>
<li>确定回溯函数的参数和返回值</li>
</ol>
<ul>
<li>可依据逻辑需要后补充参数</li>
</ul>
<blockquote>
<p><strong>可能</strong>的参数：<br>候选集合<br>问题规模为树的宽度width<br>递归深度为树的深度depth<br>当前结点问题规模的起始索引start_index<br>标记集合中元素是否已选取的数组<br>结果集合res和results</p>
</blockquote>
<ul>
<li>返回值一般为空（void）</li>
</ul>
<ol start="2">
<li>确定回溯函数的终止条件和获取结果逻辑</li>
</ol>
<ul>
<li>在树的<strong>叶子</strong>结点<strong>获取</strong>结果</li>
<li>在树的叶子结点结束当前层递归，并回溯<strong>撤销</strong>结果</li>
</ul>
<blockquote>
<p>注意：子集问题，在树的<strong>每</strong>结点获取结果</p>
</blockquote>
<ol start="3">
<li>确定回溯函数的遍历和处理结果逻辑</li>
</ol>
<ul>
<li>横向遍历当前树层各结点的问题规模</li>
<li>纵向递归<strong>处理</strong>结果</li>
</ul>
<hr>
<h1 id="四、模板"><a href="#四、模板" class="headerlink" title="四、模板"></a>四、模板</h1><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 0. 将回溯问题抽象为树形结构</span></span><br><span class="line"><span class="comment">// 1. 确定回溯函数的参数和返回值</span></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">backtrack</span><span class="params">(参数)</span> </span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="comment">// 2. 确定回溯函数的终止条件和获取结果逻辑</span></span><br><span class="line">    <span class="keyword">if</span> (终止条件) </span><br><span class="line">    &#123;</span><br><span class="line">        获取结果;</span><br><span class="line">        </span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">// 3. 确定回溯函数的遍历和处理结果逻辑</span></span><br><span class="line">    <span class="keyword">for</span> (当前树层，各结点的问题规模) </span><br><span class="line">    &#123;</span><br><span class="line">        处理结果;</span><br><span class="line">        </span><br><span class="line">        <span class="built_in">backtrack</span>(参数); <span class="comment">// 递归</span></span><br><span class="line">        </span><br><span class="line">        撤销结果; <span class="comment">// 回溯</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h1 id="五、模板示例"><a href="#五、模板示例" class="headerlink" title="五、模板示例"></a>五、模板示例</h1><p>77.组合 - 力扣（LeetCode）——中等的题解：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span></span><br><span class="line">&#123;</span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line">    <span class="comment">// 0. 将回溯问题抽象为树形结构</span></span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; res;</span><br><span class="line">    vector&lt;vector&lt;<span class="type">int</span>&gt;&gt; results;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 1. 确定回溯函数的参数和返回值</span></span><br><span class="line">    <span class="function"><span class="type">void</span> <span class="title">backtrack</span><span class="params">(<span class="type">int</span> width, <span class="type">int</span> depth, <span class="type">int</span> start_index)</span></span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// 2. 确定回溯函数的终止条件和获取结果逻辑</span></span><br><span class="line">        <span class="keyword">if</span> (res.<span class="built_in">size</span>() == depth)</span><br><span class="line">        &#123;</span><br><span class="line">            results.<span class="built_in">push_back</span>(res);</span><br><span class="line"></span><br><span class="line">            <span class="keyword">return</span>;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 3. 确定回溯函数的遍历和处理结果逻辑</span></span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> i = start_index; i &lt;= width; ++i)</span><br><span class="line">        &#123;</span><br><span class="line">            res.<span class="built_in">push_back</span>(i);       <span class="comment">// 处理结果</span></span><br><span class="line"></span><br><span class="line">            <span class="built_in">backtrack</span>(width, depth, i + <span class="number">1</span>); <span class="comment">// 递归</span></span><br><span class="line"></span><br><span class="line">            res.<span class="built_in">pop_back</span>(); <span class="comment">// 撤销结果  回溯</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    vector&lt;vector&lt;<span class="type">int</span>&gt;&gt; <span class="built_in">combine</span>(<span class="type">int</span> n, <span class="type">int</span> k)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">backtrack</span>(n, k, <span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> results;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<hr>
<h1 id="六、性能分析"><a href="#六、性能分析" class="headerlink" title="六、性能分析"></a>六、性能分析</h1><blockquote>
<p>时间复杂度：指数级</p>
</blockquote>
<p>组合问题：</p>
<ul>
<li>时间复杂度：<strong>一般</strong>为：组合规模 × 每组合判断并加入结果集的时间</li>
</ul>
<blockquote>
<p>如：$O(\complement^n_m × n)$。从m规模中取n规模，有$\complement^n_m$种组合；每组合判断并加入结果集的时间需要O(n)</p>
</blockquote>
<blockquote>
<p>如：$O(2^n × n)$。从n规模中取或不取，有$2^n$种组合；每组合判断并加入结果集的时间需要O(n)</p>
</blockquote>
<ul>
<li>空间复杂度：<strong>一般</strong>为：递归栈规模 + 结果集规模：$O(n)$。n为数据规模</li>
</ul>
<p>切割和子集问题：类似组合问题</p>
<p>排列问题：<strong>全排列</strong></p>
<ul>
<li>时间复杂度：<strong>一般</strong>为：全排列规模 × 每排列判断并加入结果集的时间：$O(n!×n)$。n为数据规模</li>
</ul>
<blockquote>
<p>参见：<br><a target="_blank" rel="noopener" href="https://leetcode.cn/problems/permutations/solution/hui-su-suan-fa-python-dai-ma-java-dai-ma-by-liweiw/">回溯算法入门级详解 + 练习（持续更新） - 全排列 - 力扣（LeetCode）</a><br><a target="_blank" rel="noopener" href="https://programmercarl.com/%E5%91%A8%E6%80%BB%E7%BB%93/20201112%E5%9B%9E%E6%BA%AF%E5%91%A8%E6%9C%AB%E6%80%BB%E7%BB%93.html#%E6%80%A7%E8%83%BD%E5%88%86%E6%9E%90">本周小结！（回溯算法系列三） | 代码随想录 (programmercarl.com)</a></p>
</blockquote>
<ul>
<li>空间复杂度：类似组合问题</li>
</ul>
<p>图和棋盘问题：具体问题具体分析</p>
<hr>
<h1 id="七、优化方法"><a href="#七、优化方法" class="headerlink" title="七、优化方法"></a>七、优化方法</h1><h2 id="1-剪枝"><a href="#1-剪枝" class="headerlink" title="1. 剪枝"></a>1. 剪枝</h2><p>作用：降低时间复杂度</p>
<p>描述：</p>
<ul>
<li>不符合条件的问题</li>
<li>不再继续处理并获取结果</li>
</ul>
<p>形式：</p>
<ul>
<li><p>横向剪枝：缩小当前树层各结点的问题规模：修改for()循环</p>
</li>
<li><p>纵向剪枝：增加终止条件</p>
</li>
</ul>
<p>模板示例：216.组合总和 III - 力扣（LeetCode）——中等的题解：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span></span><br><span class="line">&#123;</span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line">    <span class="comment">// 0. 将回溯问题抽象为树形结构</span></span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; res;</span><br><span class="line">    vector&lt;vector&lt;<span class="type">int</span>&gt;&gt; results;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 1. 确定回溯函数的参数和返回值</span></span><br><span class="line">    <span class="comment">// width：[1,9]</span></span><br><span class="line">    <span class="function"><span class="type">void</span> <span class="title">backtrack</span><span class="params">(<span class="type">int</span> depth, <span class="type">int</span> target_sum, <span class="type">int</span> start_index, <span class="type">int</span> sum)</span></span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// 2. 确定回溯函数的终止条件和获取结果逻辑</span></span><br><span class="line">        <span class="keyword">if</span> (sum &gt; target_sum) <span class="comment">// 纵向剪枝</span></span><br><span class="line">        &#123;</span><br><span class="line">            <span class="keyword">return</span>;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> (res.<span class="built_in">size</span>() == depth)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="keyword">if</span> (sum == target_sum)</span><br><span class="line">            &#123;</span><br><span class="line">                results.<span class="built_in">push_back</span>(res);</span><br><span class="line"></span><br><span class="line">                <span class="keyword">return</span>;</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">return</span>;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 3. 确定回溯函数的遍历和处理结果逻辑</span></span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> i = start_index; i &lt;= <span class="number">9</span> - (depth - res.<span class="built_in">size</span>()) + <span class="number">1</span>; ++i) <span class="comment">// 横向剪枝</span></span><br><span class="line">        &#123;</span><br><span class="line">            sum += i;</span><br><span class="line">            res.<span class="built_in">push_back</span>(i); <span class="comment">// 处理结果</span></span><br><span class="line"></span><br><span class="line">            <span class="built_in">backtrack</span>(depth, target_sum, i + <span class="number">1</span>, sum); <span class="comment">// 递归</span></span><br><span class="line"></span><br><span class="line">            sum -= i;</span><br><span class="line">            res.<span class="built_in">pop_back</span>(); <span class="comment">// 撤销结果  回溯</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    vector&lt;vector&lt;<span class="type">int</span>&gt;&gt; <span class="built_in">combinationSum3</span>(<span class="type">int</span> k, <span class="type">int</span> n)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">backtrack</span>(k, n, <span class="number">1</span>, <span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> results;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<hr>
<h1 id="八、其他技巧"><a href="#八、其他技巧" class="headerlink" title="八、其他技巧"></a>八、其他技巧</h1><h2 id="1-元素不可以和可以重复选取"><a href="#1-元素不可以和可以重复选取" class="headerlink" title="1. 元素不可以和可以重复选取"></a>1. 元素不可以和可以重复选取</h2><ul>
<li>在同一集合中，若元素不可以重复选取，则在递归时，修改当前结点问题规模的起始索引start_index</li>
</ul>
<blockquote>
<p>如：77.组合 - 力扣（LeetCode）——中等</p>
</blockquote>
<ul>
<li>在同一集合中，若元素可以重复选取，则在递归时，不修改当前结点问题规模的起始索引start_index</li>
</ul>
<blockquote>
<p>如：39.组合总和 - 力扣（LeetCode）——中等</p>
</blockquote>
<hr>
<h2 id="2-从同一集合中取和从不同集合间取元素"><a href="#2-从同一集合中取和从不同集合间取元素" class="headerlink" title="2. 从同一集合中取和从不同集合间取元素"></a>2. 从同一集合中取和从不同集合间取元素</h2><ul>
<li>从同一集合中取元素，需要参数：当前结点问题规模的起始索引start_index</li>
</ul>
<blockquote>
<p>如：77.组合 - 力扣（LeetCode）——中等</p>
</blockquote>
<ul>
<li>从不同集合间取元素，<strong>可能</strong>不需要参数：当前结点问题规模的起始索引start_index</li>
</ul>
<blockquote>
<p>如：17.电话号码的字母组合 - 力扣（LeetCode）——中等</p>
</blockquote>
<hr>
<h2 id="3-求和问题"><a href="#3-求和问题" class="headerlink" title="3. 求和问题"></a>3. 求和问题</h2><ul>
<li>在求和问题中，<strong>可能</strong>需要先排序后剪枝</li>
</ul>
<blockquote>
<p>如：39.组合总和 - 力扣（LeetCode）——中等</p>
</blockquote>
<hr>
<h2 id="4-先排序后去重"><a href="#4-先排序后去重" class="headerlink" title="4. 先排序后去重"></a>4. 先排序后去重</h2><blockquote>
<p>排序后才可以，通过相邻元素判断是否重复选取</p>
</blockquote>
<ul>
<li><strong>树层去重</strong></li>
</ul>
<blockquote>
<p>参见：<a target="_blank" rel="noopener" href="https://programmercarl.com/0040.%E7%BB%84%E5%90%88%E6%80%BB%E5%92%8CII.html">代码随想录 (programmercarl.com)</a></p>
</blockquote>
<blockquote>
<p>如：40.组合总和 II - 力扣（LeetCode）——中等</p>
</blockquote>
<blockquote>
<p>如：47.全排列 II - 力扣（LeetCode）——中等</p>
</blockquote>
<ul>
<li><strong>树枝去重</strong></li>
</ul>
<blockquote>
<p>如：47.全排列 II - 力扣（LeetCode）——中等</p>
</blockquote>
<blockquote>
<p>排列问题可以在树层去重，也可以在树枝去重；但在树层去重效率更高。参见：<a target="_blank" rel="noopener" href="https://programmercarl.com/0047.%E5%85%A8%E6%8E%92%E5%88%97II.html">代码随想录 (programmercarl.com)</a></p>
</blockquote>
<hr>
<h2 id="5-去重的方式"><a href="#5-去重的方式" class="headerlink" title="5. 去重的方式"></a>5. 去重的方式</h2><blockquote>
<p>去重：即标记集合中元素是否已选取</p>
</blockquote>
<ul>
<li>数组</li>
<li>编程语言内置的哈希表数据结构（有频繁的插入、映射、查找和删除操作，时间和空间复杂度高）。如：C++的unordered_set</li>
<li>哈希数组（已知数据规模）</li>
</ul>
<blockquote>
<p>参见：<a target="_blank" rel="noopener" href="https://programmercarl.com/%E5%9B%9E%E6%BA%AF%E7%AE%97%E6%B3%95%E5%8E%BB%E9%87%8D%E9%97%AE%E9%A2%98%E7%9A%84%E5%8F%A6%E4%B8%80%E7%A7%8D%E5%86%99%E6%B3%95.html#_90-%E5%AD%90%E9%9B%86ii">代码随想录 (programmercarl.com)</a></p>
</blockquote>
<hr>
<h2 id="6-组合、切割、排列和子集问题的区别"><a href="#6-组合、切割、排列和子集问题的区别" class="headerlink" title="6. 组合、切割、排列和子集问题的区别"></a>6. 组合、切割、排列和子集问题的区别</h2><ul>
<li><p>组合、切割和排列问题，树的叶子结点为结果（遍历符合条件的树枝）</p>
</li>
<li><p>子集问题，树的每个结点为结果（遍历树）；所以可以不需要确定回溯函数的终止条件，不存在剪枝的优化方法</p>
</li>
</ul>
<hr>
<h2 id="7-组合、切割、子集和排列问题的区别"><a href="#7-组合、切割、子集和排列问题的区别" class="headerlink" title="7. 组合、切割、子集和排列问题的区别"></a>7. 组合、切割、子集和排列问题的区别</h2><ul>
<li><p>组合问题、切割和子集问题，集合是无序的，for()循环从当前结点问题规模的起始索引start_index开始；<strong>可能</strong>需要去重</p>
</li>
<li><p>排列问题，集合是有序的，for()循环从0开始，<strong>必需</strong>去重</p>
</li>
</ul>
<hr>
<h2 id="8-二维横向遍历"><a href="#8-二维横向遍历" class="headerlink" title="8. 二维横向遍历"></a>8. 二维横向遍历</h2><ul>
<li>在二维横向遍历中</li>
<li>进行递归和回溯</li>
</ul>
<blockquote>
<p>如：37.解数独 II - 力扣（LeetCode）——困难</p>
</blockquote>
<hr>
<h1 id="九、力扣例题"><a href="#九、力扣例题" class="headerlink" title="九、力扣例题"></a>九、力扣例题</h1><p>组合问题：</p>
<ul>
<li>77.组合——中等</li>
<li>216.组合总和 III——中等</li>
<li>17.电话号码的字母组合——中等</li>
<li>39.组合总和——中等</li>
<li>40.组合总和 II——中等</li>
</ul>
<p>切割问题：</p>
<ul>
<li>131.分割回文串——中等</li>
<li>93.复原 IP 地址——中等</li>
</ul>
<p>子集问题：</p>
<ul>
<li>78.子集——中等</li>
<li>90.子集 II——中等</li>
<li>491.递增子序列——中等</li>
</ul>
<p>排列问题：</p>
<ul>
<li>46.全排列——中等</li>
<li>47.全排列 II——中等</li>
</ul>
<p>其他问题：</p>
<ul>
<li>332.重新安排行程——困难</li>
</ul>
<p>图问题：</p>
<ul>
<li>51.N 皇后——困难</li>
<li>37.解数独——困难</li>
</ul>
<hr>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>回溯描述。</p>
<hr>
<h1 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h1><ul>
<li><a target="_blank" rel="noopener" href="https://programmercarl.com/">代码随想录 (programmercarl.com)</a></li>
<li>《代码随想录》作者：孙秀洋</li>
<li><a target="_blank" rel="noopener" href="https://leetcode.cn/">力扣（LeetCode）官网 - 全球极客挚爱的技术成长平台</a></li>
</ul>
<hr>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="http://example.com">夜悊</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2023/02/13/%E5%9B%9E%E6%BA%AF%EF%BC%88backtrack%EF%BC%89%E6%8F%8F%E8%BF%B0/">http://example.com/2023/02/13/回溯（backtrack）描述/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">夜悊的技术小宅</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E7%AE%97%E6%B3%95/">算法</a></div><div class="post_share"><div class="social-share" data-image="/img/cover9.png" data-sites="qq,wechat,weibo"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/02/01/%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%EF%BC%88Dynamic%20Programming%EF%BC%89%EF%BC%88dp%EF%BC%89%E6%8F%8F%E8%BF%B0/" title="动态规划（Dynamic Programming）（dp）描述"><img class="cover" src= "" data-lazy-src="/img/cover18.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">动态规划（Dynamic Programming）（dp）描述</div></div></a></div><div class="next-post pull-right"><a href="/2023/04/14/Go%E7%9A%84%E5%B7%A5%E7%A8%8B%E7%AE%A1%E7%90%86/" title="Go的工程管理"><img class="cover" src= "" data-lazy-src="/img/cover16.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Go的工程管理</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2023/02/01/%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%EF%BC%88Dynamic%20Programming%EF%BC%89%EF%BC%88dp%EF%BC%89%E6%8F%8F%E8%BF%B0/" title="动态规划（Dynamic Programming）（dp）描述"><img class="cover" src= "" data-lazy-src="/img/cover18.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-02-01</div><div class="title">动态规划（Dynamic Programming）（dp）描述</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%89%8D%E8%A8%80"><span class="toc-number">1.</span> <span class="toc-text">前言</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5"><span class="toc-number">2.</span> <span class="toc-text">一、核心概念</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E5%85%B8%E5%9E%8B%E9%97%AE%E9%A2%98"><span class="toc-number">3.</span> <span class="toc-text">二、典型问题</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E7%AE%97%E6%B3%95%E6%AD%A5%E9%AA%A4"><span class="toc-number">4.</span> <span class="toc-text">三、算法步骤</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9B%9B%E3%80%81%E6%A8%A1%E6%9D%BF"><span class="toc-number">5.</span> <span class="toc-text">四、模板</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%94%E3%80%81%E6%A8%A1%E6%9D%BF%E7%A4%BA%E4%BE%8B"><span class="toc-number">6.</span> <span class="toc-text">五、模板示例</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%AD%E3%80%81%E6%80%A7%E8%83%BD%E5%88%86%E6%9E%90"><span class="toc-number">7.</span> <span class="toc-text">六、性能分析</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%83%E3%80%81%E4%BC%98%E5%8C%96%E6%96%B9%E6%B3%95"><span class="toc-number">8.</span> <span class="toc-text">七、优化方法</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E5%89%AA%E6%9E%9D"><span class="toc-number">8.1.</span> <span class="toc-text">1. 剪枝</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%AB%E3%80%81%E5%85%B6%E4%BB%96%E6%8A%80%E5%B7%A7"><span class="toc-number">9.</span> <span class="toc-text">八、其他技巧</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E5%85%83%E7%B4%A0%E4%B8%8D%E5%8F%AF%E4%BB%A5%E5%92%8C%E5%8F%AF%E4%BB%A5%E9%87%8D%E5%A4%8D%E9%80%89%E5%8F%96"><span class="toc-number">9.1.</span> <span class="toc-text">1. 元素不可以和可以重复选取</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E4%BB%8E%E5%90%8C%E4%B8%80%E9%9B%86%E5%90%88%E4%B8%AD%E5%8F%96%E5%92%8C%E4%BB%8E%E4%B8%8D%E5%90%8C%E9%9B%86%E5%90%88%E9%97%B4%E5%8F%96%E5%85%83%E7%B4%A0"><span class="toc-number">9.2.</span> <span class="toc-text">2. 从同一集合中取和从不同集合间取元素</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E6%B1%82%E5%92%8C%E9%97%AE%E9%A2%98"><span class="toc-number">9.3.</span> <span class="toc-text">3. 求和问题</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E5%85%88%E6%8E%92%E5%BA%8F%E5%90%8E%E5%8E%BB%E9%87%8D"><span class="toc-number">9.4.</span> <span class="toc-text">4. 先排序后去重</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-%E5%8E%BB%E9%87%8D%E7%9A%84%E6%96%B9%E5%BC%8F"><span class="toc-number">9.5.</span> <span class="toc-text">5. 去重的方式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-%E7%BB%84%E5%90%88%E3%80%81%E5%88%87%E5%89%B2%E3%80%81%E6%8E%92%E5%88%97%E5%92%8C%E5%AD%90%E9%9B%86%E9%97%AE%E9%A2%98%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="toc-number">9.6.</span> <span class="toc-text">6. 组合、切割、排列和子集问题的区别</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-%E7%BB%84%E5%90%88%E3%80%81%E5%88%87%E5%89%B2%E3%80%81%E5%AD%90%E9%9B%86%E5%92%8C%E6%8E%92%E5%88%97%E9%97%AE%E9%A2%98%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="toc-number">9.7.</span> <span class="toc-text">7. 组合、切割、子集和排列问题的区别</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#8-%E4%BA%8C%E7%BB%B4%E6%A8%AA%E5%90%91%E9%81%8D%E5%8E%86"><span class="toc-number">9.8.</span> <span class="toc-text">8. 二维横向遍历</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B9%9D%E3%80%81%E5%8A%9B%E6%89%A3%E4%BE%8B%E9%A2%98"><span class="toc-number">10.</span> <span class="toc-text">九、力扣例题</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%80%BB%E7%BB%93"><span class="toc-number">11.</span> <span class="toc-text">总结</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="toc-number">12.</span> <span class="toc-text">参考资料</span></a></li></ol></div></div></div></div></main><footer id="footer" style="background-image: url('/img/cover9.png')"><div id="footer-wrap"><div class="copyright">&copy;2023 - 2025 By 夜悊</div><div class="footer_custom_text"><a target="_blank" href="https://beian.miit.gov.cn/" >琼ICP备2023001225号-1</a><br><img src= "" data-lazy-src="/img/beian.png"/>&nbsp<a target="_blank" href="https://www.beian.gov.cn/portal/registerSystemInfo?recordcode=46010802001221" >琼公网安备 46010802001221号</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="translateLink" type="button" title="简繁转换">繁</button><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js?v=4.13.0"></script><script src="/js/main.js?v=4.13.0"></script><script src="/js/tw_cn.js?v=4.13.0"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.33/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.8/dist/lazyload.iife.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js?v=4.13.0"></script></div></div></body></html>